package com.pengpai.pangucms.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class DateUtils {
    public static String toDateString(LocalDateTime time, String pattern){
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
        // 使用format方法将LocalDateTime格式化为String
        String formattedDateTime = time.format(formatter);
        return formattedDateTime;
    }

    public static LocalDateTime toLocalDate(String dateString, String pattern){
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
        LocalDateTime localDateTime = LocalDateTime.parse(dateString, formatter);
        return localDateTime;
    }
}
